package com.fenqing.leetcode.code.t200_300;

import com.fenqing.annotations.Execute;
import com.fenqing.core.Topic;

import java.util.HashSet;
import java.util.Set;

/**
 * @author fenqing
 */
public class Topic217 extends Topic {
    /**
     * 构造器
     *
     * @param input 输入
     */
    public Topic217(String input) {
        super(input);
    }

    public static void main(String[] args) {
        Topic217 topic217 = new Topic217("[1,2,3,1]");
        boolean run = topic217.run();
        System.out.println(run);
    }

    @Execute
    public boolean containsDuplicate(int[] nums) {
        Set<Integer> set = new HashSet<>();
        for (int num : nums) {
            if (set.contains(num)){
                return true;
            }
            set.add(num);
        }
        return false;
    }
}
